'use strict'
class all {
    constructor () {

    }
    // __mid(){// 启用token-verify中间件
    //     return [
    //       {
    //         name:'token-verify',
    //         path:['list','get','post','delete']
    //       }
    //     ]
    // }
    async list (c) {
        let sqlAllPraise = `SELECT "count"(*) FROM activity`;
        let sqlAllCollect = `SELECT "count"(*) FROM collect`;
        let sqlAllUser = `SELECT "count"(*) FROM users`;
        let r1 = await c.service.psql.query(sqlAllPraise,[]);
        console.log(r1)
        let r2 = await c.service.psql.query(sqlAllCollect,[]);
        let r3 = await c.service.psql.query(sqlAllUser,[]);
        
        let obj = {
            allPraise : parseInt(r1.rows[0].count),
            allCollect : parseInt(r2.rows[0].count),
            allUser : parseInt(r3.rows[0].count)
        }
        console.log("obj：",obj);
        c.send(JSON.stringify(obj));
        
    }
}
module.exports = all;